Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

171
Vistas
Symfony3 Impossible to access an attribute ("small_pizza") on a string variable ("Margherita")

I trying to display price, but occurs error Impossible to access an attribute ("small_pizza") on a string variable ("Margherita").

This is my Controller:

/**
     * @Route(
     *      "/menu",
     *      name = "pizza_menu"
     * )
     * 
     * @Template
     */
    public function menuAction() {

        $Repo = $this->getDoctrine()->getRepository('PizzaBundle:Menu');
        $rows = $Repo->findAll();

        return array(
            'rows' => $rows
        );
    }

And this is my database: enter image description here

In a Twig code is this:

{% for entry in rows %}
   <tr>
      <td>{{ entry.id }}</td>
      <td>{{ entry.name }}</td>
      <td>{{ entry.components }}</td>
      <td>
          <ul>
              <li>{{ entry.name.small_pizza }}</li>
              <li>{{ entry.name.small_pizza }}</li>
              <li>{{ entry.name.small_pizza }}</li>
              <li>{{ entry.name.small_pizza }}</li>

          </ul>
      </td>
  </tr>

Help me please :)

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Try accessing to the prince entity navigating the relations so try this:

<li>{{ entry.price.small_pizza }}</li>

instead of

<li>{{ entry.name.small_pizza }}</li>

Hope this help

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda